IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RemoveCOIUserHierarchyMap]') AND type IN (N'P', N'PC'))
DROP PROCEDURE [dbo].[RemoveCOIUserHierarchyMap]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

/******************************************************************          
* Name:   [RemoveCOIUserHierarchyMap]          
* Purpose:  Updates the removed flag(to 1)in the COI_Hierarchy_Map.    
* Note: Removed=1-->Child is removed from the hierarchy    
*       Removed=0-->Child is added to the hierarchy    
* PARAMETERS(IN)          
* Name          Description               
* -------------      -------------------------------------------          
* @parentId       parent admpersonId     
* @childId        child admpersonId     
*********************************************************************/          
          
CREATE PROCEDURE [dbo].[RemoveCOIUserHierarchyMap]    
(          
@parentId INT,    
@childId INT,
@HierarchyTypeId INT
)          
AS BEGIN          
SET NOCOUNT ON          
          
 UPDATE COI_Hierarchy_Map 
 SET Removed = 1    
 WHERE
	 ParentId = @parentId 
 AND ChildId=@childId    
 AND HierarchyTypeId = @HierarchyTypeId
         
END 